package com.bishe.demo.config.shiro;

import com.bishe.demo.modules.account.entity.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.web.filter.authc.UserFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @Description MyUserFilter
 * @Author Lubb
 * @Date 2021/3/19 10:27
 */

public class MyUserFilter extends UserFilter {
    @Override
    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
        Session session = SecurityUtils.getSubject().getSession();
        User user = (User) session.getAttribute("user");
        return user != null && super.isAccessAllowed(request, response, mappedValue);
    }
}
